#ifndef _MEDIA_SINK_HH
#include "MediaSink.hh"
#endif
#include "MediaSession.hh"
#include "UserType.h"

class IPCameraVideoSink: public MediaSink {
public:
	static IPCameraVideoSink* createNew(UsageEnvironment& env, MediaSession* subsession, Medium* rtspclient, unsigned bufferSize = 20000, unsigned codecIndex = CODEC_H264, char *spsparameter = NULL);
	// "bufferSize" should be at least as large as the largest expected
	//   input frame.

protected:
	IPCameraVideoSink(UsageEnvironment& env, MediaSession* subsession, Medium* rtspclient, unsigned bufferSize, unsigned codecIndex = CODEC_H264, char *spsparameter = NULL);
	// called only by createNew()
	IPCameraVideoSink();
	~IPCameraVideoSink();

protected:
	static void afterGettingFrame(void* clientData, unsigned frameSize,
		unsigned numTruncatedBytes,
	struct timeval presentationTime,
		unsigned durationInMicroseconds);
	virtual void afterGettingFrame1(unsigned frameSize,
	struct timeval presentationTime);

	unsigned char* fBuffer;
	unsigned fBufferSize;
private: // redefined virtual functions:
	virtual Boolean continuePlaying();

private:
	int		m_codecIndex;
	char	m_strExtradata[2048];
	int		m_nExtrasize;
	int		m_nErrorSkipCount;
	char	m_imageData[LIMIT_IMAGE_SIZE];

private:
	MediaSession *m_mediasession;
	Medium* m_rtspclient;
	DWORD m_dwPrevTickCount;
};

